<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
    <script type="text/javascript" src="<%=ctxPath%>/lib/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="<%=ctxPath%>/lib/ueditor/ueditor.all.min.js"></script>
    <title>我要提问</title>
    <script type="text/javascript">
		function changeChapter(){
			var chapterId = $("#chapter").val();
			$.ajax({
				type:"post",
				url:"<%=ctxPath%>/question/changeChapter.do",
				data:{chapterId:chapterId},
				success:function(result){
					if(result.status=="success") {
						var data = result.data;
						$("#segment").html("");
						for (var i=0; i<data.length; i++) {
							$("#segment").append("<option value='"+data[i].id+"'>"+data[i].seqNum+" "+data[i].name+"</option>");
						}
					}
				},
				error:function(){alert("服务器连接错误");}
			});
		};
		function changeCard(){
			var cardId = $("#card").val();
			$.ajax({
				type:"post",
				url:"<%=ctxPath%>/question/changeCard.do",
				data:{cardId:cardId},
				success:function(result){
					if(result.status=="success") {
						var data = result.data;
						$("#chapter").html("");
						for (var i=0; i<data.length; i++) {
							$("#chapter").append("<option value='"+data[i].id+"'>"+data[i].seqNum+" "+data[i].name+"</option>");
						}
					}
					changeChapter();
				},
				error:function(){alert("服务器连接错误");}
			});
		}
    </script>
</head>
<body>
<%@ include file="/WEB-INF/jsp/nav.jsp" %>
    
    <div id="mainDiv"  class="container" style="margin-top: 35px;">
        <div class="panel panel-info">
            <div class="panel-heading"> 
                <h3 class="panel-title">我要提问</h3> 
            </div> 
            <div class="panel-body">
                <form action="<%=ctxPath%>/question/ask.do" method="post" onsubmit="ajaxSubmitForm(this)">
                    <div class="row">
                        <div class="col-sm-4">
                            <select class="form-control" id="card" onchange="changeCard()">
                            	<c:forEach items="${cards}" var="card">
                            		<option value="${card.id}" <c:if test="${card.id==cardId}">selected="selected"</c:if>>${card.name }</option>
                            	</c:forEach>
                            </select>
                        </div>
                        <div class="col-sm-4">
                            <select class="form-control" id="chapter" onchange="changeChapter()">
                            	<c:forEach items="${chapters}" var="chapter">
                            		<option value="${chapter.id}" <c:if test="${chapter.id==chapterId}">selected="selected"</c:if>>${chapter.seqNum} ${chapter.name}</option>
                            	</c:forEach>
                            </select>
                        </div>
                        <div class="col-sm-4">
                            <select class="form-control" id="segment" name="segmentId">
                            	<c:forEach items="${segments}" var="segment">
                                    <option value="${segment.id}" <c:if test="${segment.id==segmentId}">selected="selected"</c:if>>${segment.seqNum} ${segment.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    
                    <br/>
                    <span class="label label-danger">全部！！报错信息：</span>
                    <script id="errorInfo" name="errorInfo"  type="text/plain"></script>
                    <script type="text/javascript">
                        <!-- 实例化编辑器 -->
                        var ue1 = UE.getEditor('errorInfo',{
                            "serverUrl":"<%=ctxPath%>/upload.do",
                            "elementPathEnabled" : false,
                            "wordCount":false,
                            "initialFrameHeight":200,
                            "toolbars":[ ['simpleupload','emotion','attachment'] ]
                        });
                    </script>                        
                    
                    <br/>
                    <span class="label label-danger">相关代码：</span>
                    <script id="errorCode" name="errorCode"  type="text/plain"></script>
                    <script type="text/javascript">
                        <!-- 实例化编辑器 -->
                        var ue2 = UE.getEditor('errorCode',{
                            "serverUrl":"<%=ctxPath%>/upload.do",
                            "elementPathEnabled" : false,
                            "wordCount":false,
                            "initialFrameHeight":200,
                            "toolbars":[ ['simpleupload','emotion','attachment'] ]
                        });
                    </script>                        
                    
                    <br/>
                    <span class="label label-danger">问题描述：</span>
                    <script id="description" name="description"  type="text/plain"></script>
                    <script type="text/javascript">
                        <!-- 实例化编辑器 -->
                        var ue3 = UE.getEditor('description',{
                            "serverUrl":"<%=ctxPath%>/upload.do",
                            "elementPathEnabled" : false,
                            "wordCount":false,
                            "initialFrameHeight":200,
                            "toolbars":[ ['simpleupload','emotion','attachment'] ]
                        });
                    </script>
                    <br/>
                    <input type="submit"  class="btn btn-default" value="提交问题" />
                </form>
            </div> 
        </div>
    </div>
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
</body>
</html>